import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import 'element-ui/lib/theme-chalk/index.css';
import './assets/css/style.css'
import './assets/css/flexCommon.css'


import utils from './assets/js/utils.js' //工具类 时间格式化等
Vue.prototype.utils = utils;

import Element from 'element-ui';
Vue.use(Element, { size: 'small' });

Vue.config.productionTip = false

router.beforeEach((to, from, next) => {
    // console.log(store.state.headerActiveTab)
    // console.log(to.name, to.path)

    /**分类切换的时候要重新加载过暑假 */
    if (to.meta.type_id != undefined) {
        store.state.Classify.classifyListId = to.meta.classifyListId;
        store.state.Classify.type_id = to.meta.type_id; // 0、其他 1、jquery 2、javascript 3、vue 4、uniapp
        // /**拷贝初始值 重新加载分类下拉*/
        store.state.Classify.addClassifyFormCopy = { ...store.state.Classify.addClassifyForm };
        store.state.Classify.classifyRadio = 1;
        store._actions['Classify/seachQuery'][0]('参数')
        /**重新加载加载list*/
        store.state.Classify.searchData.name = '';
        store.state.Classify.searchData.classifyOneId = '';
        store.state.Classify.searchDataclassifyTwoId = '';
        store._actions['Classify/list'][0]('')
    }
    /**header组件里面的标签tab */
    let headerTabs = store.state.headerTabs;
    store.state.headerActiveTab = to.name;//当前
    for (let i = 0; i < headerTabs.length; i++) {//是否已存在
        if (headerTabs[i].name == to.name) {
            next();
            return;
        }
    }
    if (to.name != undefined) {
        headerTabs.push({ name: to.name, path: to.path });//添加到数组里面
        next();
    }
    else {
        next('/dashboard')
    }
})

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')
